package com.ruoyi.web.controller.drone_certification;

import com.alibaba.druid.sql.dialect.odps.ast.OdpsUndoTableStatement;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.drone_certification.domain.DroneCertification;
import com.ruoyi.drone_certification.service.IDroneCertificationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 无人机认证Controller
 * 
 * @author ruoyi
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/Drone_certification/drone_certification")
public class DroneCertificationController extends BaseController
{
    @Autowired
    private IDroneCertificationService droneCertificationService;

    /**
     * 查询无人机认证列表
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:list')")
    @GetMapping("/list")
    public TableDataInfo list(DroneCertification droneCertification,String maniName)
    {

//        System.out.println(droneCertification);
        startPage();
        if (maniName!=null){
//            System.err.println(maniName);
            List<DroneCertification> droneCertifications = droneCertificationService.selectDroneCertificationList(maniName);
            return getDataTable(droneCertifications);
        }
        List<DroneCertification> list = droneCertificationService.selectDroneCertificationList(droneCertification);
        return getDataTable(list);
    }

    /**
     * 导出无人机认证列表
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:export')")
    @Log(title = "无人机认证", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DroneCertification droneCertification)
    {
        List<DroneCertification> list = droneCertificationService.selectDroneCertificationList(droneCertification);
        ExcelUtil<DroneCertification> util = new ExcelUtil<DroneCertification>(DroneCertification.class);
        util.exportExcel(response, list, "无人机认证数据");
    }

    /**
     * 获取无人机认证详细信息
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(droneCertificationService.selectDroneCertificationById(id));
    }

    /**
     * 新增无人机认证
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:add')")
    @Log(title = "无人机认证", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DroneCertification droneCertification)
    {
        return toAjax(droneCertificationService.insertDroneCertification(droneCertification));
    }

    /**
     * 修改无人机认证
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:edit')")
    @Log(title = "无人机认证", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DroneCertification droneCertification)
    {
        return toAjax(droneCertificationService.updateDroneCertification(droneCertification));
    }

    /**
     * 删除无人机认证
     */
    @PreAuthorize("@ss.hasPermi('Drone_certification:drone_certification:remove')")
    @Log(title = "无人机认证", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(droneCertificationService.deleteDroneCertificationByIds(ids));
    }
}
